﻿using System.Text;
using System.Web;

namespace com.fukefu.source
{
    public class ParametersData
    {
        StringBuilder sb = new StringBuilder();
        string bianma = "";
        public ParametersData()
        {
            bianma = "utf-8";
        }
        public ParametersData(string bianma)
        {
            this.bianma = bianma;
        }
        public void Add(string key, string value)
        {
            sb.Append((sb.Length == 0 ? "" : "&") + key + "=" + HttpUtility.UrlEncode(value, Encoding.GetEncoding(bianma)));
        }
        public void Add(string value)
        {
            if (value.StartsWith("&"))
            {
                sb.Append(value.Substring(sb.Length > 0 ? 0 : 1));
            }
            else
            {
                sb.Append((sb.Length == 0 ? "" : "&") + value);
            }
        }
        public string Read()
        {
            return sb.ToString();
        }
    }
}
